home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-18 | 3.7 KB | 164 lines | [TEXT/R*ch] |
- // (c) copyright 1995,1996, Jon Kalb, Liberty Software
- // Kalb@LibertySoft.com
- // You may freely incorporate this code into any machine-
- // readable project. You may modify this code, but you may
- // not remove this statement.
-
- #define d(s) s
-
-
- #ifdef COMMENT
-
- In my testing, I found that with CodeWarrior, dout was
- constructed in time for use by by static object, but not
- with Think Project Manager. (This is not a fault of TPM,
- because the language does not guarantee that it will
- be.)
-
- I also found that the library provided with CodeWarrior
- did not properly format the "+0x64" at the end of the
- test, but TPM did. (With CodeWarrior it came out as
- +100.)
-
- #endif // COMMENT
-
- #include "doutstream"
-
- #include "streamstructsmac.h"
-
- #ifdef COMMENT
-
- The privateMembers example is included only to show how
- to create overloads that access private (or protected)
- members.
-
- #endif // COMMENT
-
- class privateMembers
- {
- // This example is included only to show how to create
- // insertion operator overloads that access private (or
- // protected) members.
- public:
- privateMembers() {fA = 3; fB = 2;};
- ~privateMembers() {};
- private:
- int fA;
- int fB;
-
- friend ostream &operator<<(ostream &stream,
- const privateMembers &rhs);
- };
-
- ostream &operator<<(ostream &stream,
- const privateMembers &rhs);
-
- ostream &operator<<(ostream &stream,
- const privateMembers &rhs)
- {
- stream << ".fA(" << rhs.fA << ") ";
- stream << ".fB(" << rhs.fB << ") ";
- return stream;
- }
-
- #ifdef COMMENT
-
- The staticObject example is included only to illustrate
- the use of dout in the constructor of a static object.
-
- #endif // COMMENT
-
- class staticObject
- {
- public:
- staticObject();
- ~staticObject();
- };
-
- staticObject::staticObject()
- {
- // this may cause us great problems depending on
- // whether or not dout has been constructed
- // dout << "staticObject::staticObject()\n";
- }
-
- staticObject::~staticObject()
- {
- dout << "staticObject::~staticObject()\n";
- }
-
- static staticObject charlie;
-
-
- int main()
- {
- dout << doutformfeed;
-
- dout << "streaming strings, chars, and ints\n";
- dout << 'M' << 'a' << 'c' << ' ' << 1984 << endl;
-
- dout << doutformfeed;
-
- dout << "streaming special characters\n";
- dout << "backspace > " << doutbackspace <<
- "< is there a space?" << endl;
- dout << "form feed" << doutformfeed << endl;
- dout << "new " << '\n' << endl << '\n';
- dout << "return " << '\r' << endl << '\r';
- dout << "tab " << douttab << "is this tabbed?" << endl;
- dout << "vert " << doutverttab << "is this tabbed?"
- << endl;
- dout << "alert " << doutsysbeep << endl;
- dout << "null are we in the debugger? " << doutdropin
- << endl;
- dout << "EOT are we in the debugger? " << '\x3' << endl;
-
-
- dout << doutformfeed;
-
- dout << "streaming a object with private members\n";
- privateMembers pmObject;
-
- dout << pmObject << endl;
-
- dout << doutformfeed;
-
- dout << "streaming a Macintosh structures\n";
- Point p;
- Rect r;
- BitMap b;
-
- p.v = 1; p.h = 2;
- r.top = 3; r.left = 4; r.bottom = 5; r.right = 6;
- b.baseAddr = (Ptr)0x12345678; b.rowBytes = 7;
- b.bounds = r;
-
- dout << "point: " << p << endl;
- dout << "rect: " << r << endl;
- dout << "bitmap: " << endl;
- dout << b << doutdebug; // drops us in the debugger
-
- dout << doutformfeed;
-
- char test[] = "This is a test of MacsBug commands";
- dout << doutcommand << "dm #" << (unsigned long)test
- << doutsoftflush;
-
- dout << doutformfeed;
- dout << "fun and games with standard streams\n";
- showflags(dout);
- dout.setf(ios::right | ios::showpoint | ios::fixed);
- dout << showflags;
- dout.setf(ios::showpos);
- dout.setf(ios::hex);
- dout.setf(ios::showbase);
- dout << showflags;
- dout << 100;
- dout << " this should be +0x64. If it isn't the";
- dout << " implementation of your standard library";
- dout << " is suspect.\n";
-
- return 0;
- }
-
-